import axios from 'axios';
import { getLang } from '@/utils/util';
import { REQUEST_ADDRESS_LOCAL, REQUEST_ADDRESS, IMGURL_API } from '@/utils/constant';

export default {

  // 图标上传
  iconUpload(data) {
    return window._UIDesingerAxios({
      url: '/quality/api/v1/file/uploadFile',
      method: 'post',
      data: data,
    });
  },

  xvueIconUpload(data, siteId, widgetInstanceId) {
    const uploadUrl = `/xvue-admin/api/files?siteUuid=${siteId}&instanceUuid=${widgetInstanceId}`;
    return window._UIDesingerAxios({
      method: 'post',
      url: uploadUrl,
      data,
    });
  },

  // 获取图片上传记录
  xvueGetIconHistories() {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/library/get?assetsCode=visual-components',
      method: 'get',
    });
  },

  deleteIconHistories(iconIds) {
    return window._UIDesingerAxios({
      url: '/xvue-admin/api/library/remove',
      method: 'post',
      data: {
        assetsCode: 'visual-components',
        removeId: iconIds,
      },
    });
  },

  // 获取多语言，仅本地使用
  getI18n() {
    const lang = getLang();

    return window._UIDesingerAxios({
      url: '/publici18nservice/i18n/v1/localevalue/localeandtagbybatch',
      method: 'get',
      params: {
        locale: lang,
        tags: 'VisualComponents',
      },
    });
  },
};
